package com.heima.article.controller.v1;

import com.heima.article.service.AuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @package com.heima.article.controller.v1
 * @Date 2022/2/27
 * @project heima-leadnews
 */
@Api(value = "作者管理API",tags = "作者管理API")
@RestController
@RequestMapping("/api/v1/author")
public class ArticleController {
    @Autowired
    private AuthorService authorService;
    @ApiOperation(value = "保存作者信息")
    @PostMapping("save")
    public ResponseResult<ApAuthor> insertWmUser(@RequestBody ApAuthor apAuthor){
        authorService.save(apAuthor);
        return ResponseResult.okResult(apAuthor);
    }
    @ApiOperation("根据名称查询")
    @GetMapping("/findByUserId/{userId}")
    public ResponseResult<ApAuthor>  selectById(@PathVariable("userId") Integer userId){
        return ResponseResult.okResult(authorService.getById(userId));
    }
}
